package per.sunmes.lesrb.util;

import com.badlogic.gdx.math.MathUtils;

/**
 * MathUtil
 */
public class MU {

	public static double calcDegreeOfTrianges(float px, float py, float ax, float ay, float bx, float by) {
		double lineP = lengthOfTwoPoint(ax, ay, bx, by);
		if (lineP == 0) {
			return 0;
		}
		double lineA = lengthOfTwoPoint(ax, ay, px, py);
		double lineB = lengthOfTwoPoint(bx, by, px, py);
		return caleDegreeOfTriangles(lineP, lineA, lineB);
	}

	public static double caleDegreeOfTriangles(double lenP, double lenA, double lenB) {
		return Math.acos((lenA * lenA + lenB * lenB - lenP * lenP) / (2 * lenA * lenB)) * MathUtils.radiansToDegrees;
	}

	public static double lengthOfTwoPoint(float ax, float ay, float bx, float by) {
		return Math.sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
	}

}
